package com.huawei.esdk.tp.northcommu.cxf.professional;

import java.util.Date;
import java.util.List;
import org.apache.log4j.Logger;
import com.huawei.esdk.platform.common.SDKErrorCode;
import com.huawei.esdk.platform.common.SDKResult;
import com.huawei.esdk.platform.common.config.ConfigManager;
import com.huawei.esdk.platform.common.exception.SDKException;
import com.huawei.esdk.platform.common.utils.DateUtils;
import com.huawei.esdk.platform.common.utils.DurationUtils;
import com.huawei.esdk.platform.common.utils.StringUtils;
import com.huawei.esdk.tp.business.professional.confmgr.ConfManagerService;
import com.huawei.esdk.tp.common.ErrInfo;
import com.huawei.esdk.tp.domain.model.Conference;
import com.huawei.esdk.tp.domain.model.PeriodicalConference;
import com.huawei.esdk.tp.domain.model.ScheduleConference;
import com.huawei.esdk.tp.domain.model.Site;
import com.huawei.esdk.tp.domain.model.SiteInConference;
import com.huawei.esdk.tp.domain.model.bean.AdhocConfFreeBusyStateList;
import com.huawei.esdk.tp.domain.model.bean.AdhocConferencesList;
import com.huawei.esdk.tp.domain.model.bean.ContinuousPresenceCapability;
import com.huawei.esdk.tp.domain.model.bean.ContinuousPresenceParam;
import com.huawei.esdk.tp.domain.model.bean.DateTimeRange;
import com.huawei.esdk.tp.domain.model.bean.MultiPointCDRQueryConfig;
import com.huawei.esdk.tp.domain.model.bean.MultiPointCDRResult;
import com.huawei.esdk.tp.domain.model.bean.PagedList;
import com.huawei.esdk.tp.domain.model.bean.PointToPointCDR;
import com.huawei.esdk.tp.domain.model.bean.PointToPointCDRQueryConfig;
import com.huawei.esdk.tp.domain.model.bean.SiteMCU;
import com.huawei.esdk.tp.northcommu.cxf.professional.convert.TPProfessionalConfMgrConvert;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.AddSiteToConfEx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.AddSiteToConfExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.ConnectSitesEx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.ConnectSitesExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.DelScheduledConfEx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.DelScheduledConfExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.DelSiteFromConfEx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.DelSiteFromConfExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.DisconnectSitesEx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.DisconnectSitesExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.EditRecurrenceConferenceEx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.EditRecurrenceConferenceExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.EditScheduledConfEx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.EditScheduledConfExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.GetContinuousPresenceInfoEx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.GetContinuousPresenceInfoExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.GetContinuousPresenceParamEx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.GetContinuousPresenceParamExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.ProlongScheduledConfEx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.ProlongScheduledConfExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.QueryAdhocConfFreeBusyEx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.QueryAdhocConfFreeBusyExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.QueryAdhocConferencesEx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.QueryAdhocConferencesExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.QueryConfSiteMCUEx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.QueryConfSiteMCUExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.QueryConfSitesStatusEx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.QueryConfSitesStatusExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.QueryConferencesStatusEx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.QueryConferencesStatusExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.QueryMultiPointCDREx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.QueryMultiPointCDRExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.QueryPointToPointCDREx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.QueryPointToPointCDRExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.QuerySiteStatusEx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.QuerySiteStatusExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.QuerySitesEx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.QuerySitesExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.ScheduleConfEx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.ScheduleConfExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.ScheduleRecurrenceConferenceEx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.ScheduleRecurrenceConferenceExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.SynchAdhocConfFreeBusyEx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.SynchAdhocConfFreeBusyExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.SynchSiteStatusEx;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.SynchSiteStatusExResponse;
import com.huawei.esdk.tp.northcommu.cxf.professional.gen.TPProfessionalConfMgr;

/** * @author w00208247 * * */
public class TPProfessionalConfMgrImpl implements TPProfessionalConfMgr
{
    
    private ConfManagerService confManagerService;
    
    private static final Logger LOGGER = Logger.getLogger(TPProfessionalConfMgrImpl.class);
    
    private TPProfessionalConfMgrConvert tpProfessionalConfMgrConvertService;
    
    /**
     * * @see com.huawei.esdk.tp.northcommu.cxf.professional.gen.
     * TPProfessionalConfMgr
     * #querySitesEx(com.huawei.esdk.tp.northcommu.cxf.professional
     * .gen.QuerySitesEx)
     */
    
    @Override
    public QuerySitesExResponse querySitesEx(QuerySitesEx parameters)
    {
        QuerySitesExResponse response = new QuerySitesExResponse();
        try
        {
            if (null == parameters)
            {
                response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
                return response;
            }
            SDKResult<PagedList<Site>> sites = confManagerService.querySites();
            response = tpProfessionalConfMgrConvertService.sdkResult2QuerySitesExResponse(sites);
        }
        catch (SDKException ex)
        {
            LOGGER.error("querySitesEx method error", ex);
            response.setResultCode((int)ex.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("querySitesEx method error", e);
            response.setResultCode((int)ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        return response;
    }
    
    /**
     * * @see com.huawei.esdk.tp.northcommu.cxf.professional.gen.
     * TPProfessionalConfMgr
     * #editRecurrenceConferenceEx(com.huawei.esdk.tp.northcommu
     * .cxf.professional.gen.EditRecurrenceConferenceEx)
     */
    @Override
    public EditRecurrenceConferenceExResponse editRecurrenceConferenceEx(EditRecurrenceConferenceEx parameters)
    {
        SDKResult<PeriodicalConference> result = null;
        EditRecurrenceConferenceExResponse response = new EditRecurrenceConferenceExResponse();
        try
        {
            if (null == parameters || null == parameters.getEditConf() || null == parameters.getEditConf().getSites())
            {
                response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
                return response;
            }
            
            //R5C00适配，与TP OA保持一致，编辑周期会议需要增加子会议开始时间
            result =
                confManagerService.editScheduleRecurrenceConfResponseService(tpProfessionalConfMgrConvertService.editScheduledRecurrenceConfSoap2model(parameters),
                    DateUtils.toDate(parameters.getBeginTime()));
            // 将领域bean的返回值改成北向soapbean的返回值
            response = tpProfessionalConfMgrConvertService.editScheduledRecurrenceConfModel2soap(result);
        }
        catch (SDKException e)
        {
            LOGGER.error("editRecurrenceConferenceEx method SDK error", e);
            response.setResultCode((int)e.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("editRecurrenceConferenceEx method error", e);
            response.setResultCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        return response;
    }
    
    /**
     * * @see com.huawei.esdk.tp.northcommu.cxf.professional.gen.
     * TPProfessionalConfMgr
     * #synchSiteStatusEx(com.huawei.esdk.tp.northcommu.cxf.
     * professional.gen.SynchSiteStatusEx)
     */
    @Override
    public SynchSiteStatusExResponse synchSiteStatusEx(SynchSiteStatusEx parameters)
    {
        SynchSiteStatusExResponse response = new SynchSiteStatusExResponse();
        
        try
        {
            if (null == parameters || null == parameters.getSiteUris())
            {
                response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
                return response;
            }
            DateTimeRange timeRange =
                tpProfessionalConfMgrConvertService.synchSiteStatusSoap2model(parameters.getBeginTime(),
                    parameters.getDuration());
            SDKResult<List<Site>> result = confManagerService.synchSiteStatus(parameters.getSiteUris(), timeRange);
            response = tpProfessionalConfMgrConvertService.synchSiteStatusModel2soap(result);
        }
        catch (SDKException ex)
        {
            LOGGER.error("synchSiteStatusEx method error", ex);
            response.setResultCode((int)ex.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("synchSiteStatusEx method error", e);
            response.setResultCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        return response;
    }
    
    /**
     * * @see com.huawei.esdk.tp.northcommu.cxf.professional.gen.
     * TPProfessionalConfMgr
     * #queryConferencesStatusEx(com.huawei.esdk.tp.northcommu
     * .cxf.professional.gen.QueryConferencesStatusEx)
     */
    @Override
    public QueryConferencesStatusExResponse queryConferencesStatusEx(QueryConferencesStatusEx parameters)
    {
        QueryConferencesStatusExResponse response = new QueryConferencesStatusExResponse();
        try
        {
            if (null == parameters)
            {
                response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
                return response;
            }
            SDKResult<List<Conference>> result = confManagerService.queryConferencesStatus(parameters.getConfIds());
            response = tpProfessionalConfMgrConvertService.queryConferencesStatusModel2soap(result);
        }
        catch (SDKException ex)
        {
            LOGGER.error("queryConferencesStatusEx method error", ex);
            response.setResultCode((int)ex.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("queryConferencesStatusEx method error", e);
            response.setResultCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        return response;
    }
    
    /**
     * * @see com.huawei.esdk.tp.northcommu.cxf.professional.gen.
     * TPProfessionalConfMgr
     * #querySiteStatusEx(com.huawei.esdk.tp.northcommu.cxf.
     * professional.gen.QuerySiteStatusEx)
     */
    @Override
    public QuerySiteStatusExResponse querySiteStatusEx(QuerySiteStatusEx parameters)
    {
        QuerySiteStatusExResponse response = new QuerySiteStatusExResponse();
        try
        {
            if (null == parameters || null == parameters.getSiteUris())
            {
                response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
                return response;
            }
            DateTimeRange timeRange =
                tpProfessionalConfMgrConvertService.querySiteStatusSoap2model(parameters.getBeginTime(),
                    parameters.getDuration());
            SDKResult<List<Site>> result = confManagerService.querySiteStatus(parameters.getSiteUris(), timeRange);
            
            response = tpProfessionalConfMgrConvertService.querySiteStatusModel2soap(result);
        }
        catch (SDKException ex)
        {
            LOGGER.error("querySiteStatusEx method error", ex);
            response.setResultCode((int)ex.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("querySiteStatusEx method error", e);
            response.setResultCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        return response;
    }
    
    /**
     * * @see com.huawei.esdk.tp.northcommu.cxf.professional.gen.
     * TPProfessionalConfMgr
     * #addSiteToConfEx(com.huawei.esdk.tp.northcommu.cxf.professional
     * .gen.AddSiteToConfEx)
     */
    @Override
    public AddSiteToConfExResponse addSiteToConfEx(AddSiteToConfEx parameters)
    {
        AddSiteToConfExResponse response = new AddSiteToConfExResponse();
        try
        {
            if (null == parameters)
            {
                response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
                return response;
            }
            if (null == parameters.getSiteInfo())
            {
                response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
                return response;
            }
            SDKResult<List<SiteInConference>> result =
                confManagerService.addSiteToConfEx(parameters.getConfId(),
                    tpProfessionalConfMgrConvertService.addSiteToConfSoap2model(parameters.getSiteInfo()),
                    parameters.getBeginTime());
            response = tpProfessionalConfMgrConvertService.model2AddSiteToConfSoap(result);
        }
        catch (SDKException e)
        {
            LOGGER.error("addSiteToConfEx method SDK error", e);
            response.setResultCode((int)e.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("addSiteToConfEx error", e);
            response.setResultCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        return response;
    }
    
    /**
     * * @see com.huawei.esdk.tp.northcommu.cxf.professional.gen.
     * TPProfessionalConfMgr
     * #delScheduledConfEx(com.huawei.esdk.tp.northcommu.cxf
     * .professional.gen.DelScheduledConfEx)
     */
    @Override
    public DelScheduledConfExResponse delScheduledConfEx(DelScheduledConfEx parameters)
    {
        DelScheduledConfExResponse response = new DelScheduledConfExResponse();
        try
        {
            if (null == parameters)
            {
                response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
                return response;
            }
            SDKErrorCode errorCode =
                confManagerService.delScheduledConf(parameters.getConfId(), parameters.getBeginTime());
            response.setResultCode((int)errorCode.getErrCode());
        }
        catch (SDKException ex)
        {
            LOGGER.error("delScheduledConfEx method error", ex);
            response.setResultCode((int)ex.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("delScheduledConfEx method error", e);
            response.setResultCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        return response;
    }
    
    /**
     * * @see com.huawei.esdk.tp.northcommu.cxf.professional.gen.
     * TPProfessionalConfMgr
     * #queryConfSitesStatusEx(com.huawei.esdk.tp.northcommu
     * .cxf.professional.gen.QueryConfSitesStatusEx)
     */
    @Override
    public QueryConfSitesStatusExResponse queryConfSitesStatusEx(QueryConfSitesStatusEx parameters)
    {
        QueryConfSitesStatusExResponse response = new QueryConfSitesStatusExResponse();
        try
        {
            if (null == parameters || StringUtils.isEmpty(parameters.getConfId()))
            {
                response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
                return response;
            }
            SDKResult<List<SiteInConference>> result =
                confManagerService.queryConfSitesStatus(parameters.getConfId(), parameters.getSiteUris());
            
            response = tpProfessionalConfMgrConvertService.queryConfSitesStatusModel2soap(result);
        }
        catch (SDKException ex)
        {
            LOGGER.error("queryConfSitesStatusEx method error", ex);
            response.setResultCode((int)ex.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("queryConfSitesStatusEx method error", e);
            response.setResultCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        return response;
    }
    
    /**
     * * @see com.huawei.esdk.tp.northcommu.cxf.professional.gen.
     * TPProfessionalConfMgr
     * #prolongScheduledConfEx(com.huawei.esdk.tp.northcommu
     * .cxf.professional.gen.ProlongScheduledConfEx)
     */
    @Override
    public ProlongScheduledConfExResponse prolongScheduledConfEx(ProlongScheduledConfEx parameters)
    {
        ProlongScheduledConfExResponse response = new ProlongScheduledConfExResponse();
        try
        {
            if (null == parameters)
            {
                response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
                return response;
            }
            SDKErrorCode result =
                confManagerService.prolongScheduledConf(parameters.getConfId(),
                    DateUtils.toDate(parameters.getBeginDate()),
                    DurationUtils.duration2int(parameters.getProlongTime()));
            response.setResultCode((int)result.getErrCode());
        }
        catch (SDKException ex)
        {
            LOGGER.error("prolongScheduledConfEx method error", ex);
            response.setResultCode((int)ex.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("prolongScheduledConfEx method error", e);
            response.setResultCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        
        return response;
    }
    
    /**
     * * @see com.huawei.esdk.tp.northcommu.cxf.professional.gen.
     * TPProfessionalConfMgr
     * #scheduleConfEx(com.huawei.esdk.tp.northcommu.cxf.professional
     * .gen.ScheduleConfEx)
     */
    @Override
    public ScheduleConfExResponse scheduleConfEx(ScheduleConfEx parameters)
    {
        SDKResult<ScheduleConference> result = null;
        ScheduleConfExResponse response = new ScheduleConfExResponse();
        try
        {
            if (null == parameters || null == parameters.getScheduleConf()
                || null == parameters.getScheduleConf().getSites())
            {
                response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
                return response;
            }
            result =
                confManagerService.scheduleConfResponseService(tpProfessionalConfMgrConvertService.scheduleConfSoap2model(parameters));
            // 将领域bean的返回值改成北向soapbean的返回值
            response = tpProfessionalConfMgrConvertService.scheduleConferenceModel2soap(result);
        }
        catch (SDKException e)
        {
            LOGGER.error("scheduleConfEx method error", e);
            response.setResultCode((int)e.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("scheduleConfEx method error", e);
            response.setResultCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        return response;
    }
    
    /**
     * * @see com.huawei.esdk.tp.northcommu.cxf.professional.gen.
     * TPProfessionalConfMgr
     * #disconnectSitesEx(com.huawei.esdk.tp.northcommu.cxf.
     * professional.gen.DisconnectSitesEx)
     */
    @Override
    public DisconnectSitesExResponse disconnectSitesEx(DisconnectSitesEx parameters)
    {
        DisconnectSitesExResponse response = new DisconnectSitesExResponse();
        try
        {
            if (null == parameters || null == parameters.getSiteUris())
            {
                response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
                return response;
            }
            SDKErrorCode errorCode =
                confManagerService.disconnectSites(parameters.getConfId(), parameters.getSiteUris());
            
            response.setResultCode(Integer.parseInt(String.valueOf(errorCode.getErrCode())));
        }
        catch (SDKException e)
        {
            LOGGER.error("disconnectSitesEx method error", e);
            response.setResultCode((int)e.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("disconnectSitesEx method error", e);
            response.setResultCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        return response;
    }
    
    /**
     * * @see com.huawei.esdk.tp.northcommu.cxf.professional.gen.
     * TPProfessionalConfMgr
     * #connectSitesEx(com.huawei.esdk.tp.northcommu.cxf.professional
     * .gen.ConnectSitesEx)
     */
    @Override
    public ConnectSitesExResponse connectSitesEx(ConnectSitesEx parameters)
    {
        ConnectSitesExResponse response = new ConnectSitesExResponse();
        try
        {
            if (null == parameters || null == parameters.getSiteUris())
            {
                response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
                return response;
            }
            SDKErrorCode errorCode = confManagerService.connectSites(parameters.getConfId(), parameters.getSiteUris());
            
            response.setResultCode(Integer.parseInt(String.valueOf(errorCode.getErrCode())));
        }
        catch (SDKException e)
        {
            LOGGER.error("connectSitesEx method error", e);
            response.setResultCode((int)e.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("connectSitesEx method error", e);
            response.setResultCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        return response;
    }
    
    /**
     * * @see com.huawei.esdk.tp.northcommu.cxf.professional.gen.
     * TPProfessionalConfMgr
     * #delSiteFromConfEx(com.huawei.esdk.tp.northcommu.cxf.
     * professional.gen.DelSiteFromConfEx)
     */
    @Override
    public DelSiteFromConfExResponse delSiteFromConfEx(DelSiteFromConfEx parameters)
    {
        DelSiteFromConfExResponse response = new DelSiteFromConfExResponse();
        SDKErrorCode result = null;
        try
        {
            if (null == parameters)
            {
                response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
                return response;
            }
            String confId = parameters.getConfId();
            String siteUri = parameters.getSiteUri();
            Date beginTime = DateUtils.toDate(parameters.getBeginTime());
            result = confManagerService.delSiteFromConfEx(confId, siteUri, beginTime);
        }
        catch (SDKException ex)
        {
            LOGGER.error("", ex);
            result = new SDKErrorCode();
            result.setErrCode((int)ex.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("delSiteFromConfEx method error", e);
            result.setErrCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        
        response.setResultCode((int)result.getErrCode());
        
        return response;
    }
    
    public TPProfessionalConfMgrConvert getTpProfessionalConfMgrConvertService()
    {
        return tpProfessionalConfMgrConvertService;
    }
    
    public void setTpProfessionalConfMgrConvertService(TPProfessionalConfMgrConvert tpProfessionalConfMgrConvertService)
    {
        this.tpProfessionalConfMgrConvertService = tpProfessionalConfMgrConvertService;
    }
    
    public ConfManagerService getConfManagerService()
    {
        return confManagerService;
    }
    
    public void setConfManagerService(ConfManagerService confManagerService)
    {
        this.confManagerService = confManagerService;
    }
    
    /**
     * * @see com.huawei.esdk.tp.northcommu.cxf.professional.gen.
     * TPProfessionalConfMgr
     * #editScheduledConfEx(com.huawei.esdk.tp.northcommu.cxf
     * .professional.gen.EditScheduledConfEx)
     */
    @Override
    public EditScheduledConfExResponse editScheduledConfEx(EditScheduledConfEx parameters)
    {
        SDKResult<ScheduleConference> result = null;
        EditScheduledConfExResponse response = new EditScheduledConfExResponse();
        try
        {
            if (null == parameters || null == parameters.getEditConf() || null == parameters.getEditConf().getSites())
            {
                response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
                return response;
            }
            result =
                confManagerService.editScheduleConfResponseService(tpProfessionalConfMgrConvertService.editScheduledConfSoap2model(parameters));
            // 将领域bean的返回值改成北向soapbean的返回值
            response = tpProfessionalConfMgrConvertService.editScheduledConfModel2soap(result);
        }
        catch (SDKException e)
        {
            LOGGER.error("editScheduledConfEx method SDK error", e);
            response.setResultCode((int)e.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("editScheduledConfEx method error", e);
            response.setResultCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        return response;
    }
    
    /**
     * * @see com.huawei.esdk.tp.northcommu.cxf.professional.gen.
     * TPProfessionalConfMgr
     * #scheduleRecurrenceConferenceEx(com.huawei.esdk.tp.northcommu
     * .cxf.professional.gen.ScheduleRecurrenceConferenceEx)
     */
    @Override
    public ScheduleRecurrenceConferenceExResponse scheduleRecurrenceConferenceEx(
        ScheduleRecurrenceConferenceEx parameters)
    {
        // PeriodicalConference,周期会议
        SDKResult<PeriodicalConference> result = null;
        ScheduleRecurrenceConferenceExResponse response = new ScheduleRecurrenceConferenceExResponse();
        try
        {
            if (null == parameters || null == parameters.getScheduleConf()
                || null == parameters.getScheduleConf().getSites())
            {
                response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
                return response;
            }
            result =
                confManagerService.scheduleRecurrenceConfResponseService(tpProfessionalConfMgrConvertService.scheduleRecurrenceConfSoap2model(parameters));
            // 将领域bean的返回值改成北向soapbean的返回值
            response = tpProfessionalConfMgrConvertService.scheduleRecurrenceConfModel2soap(result);
        }
        catch (SDKException e)
        {
            LOGGER.error("scheduleRecurrenceConferenceEx method SDK error", e);
            response.setResultCode((int)e.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("scheduleRecurrenceConferenceEx method error", e);
            response.setResultCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        return response;
    }
    
    @Override
    public QueryPointToPointCDRExResponse queryPointToPointCDREx(QueryPointToPointCDREx parameters)
    {
        QueryPointToPointCDRExResponse response = new QueryPointToPointCDRExResponse();
        try
        {
            if (null == parameters || null == parameters.getQueryConfig().getBeginTime()
                || null == parameters.getQueryConfig().getDuration()
                || null == parameters.getQueryConfig().getPageParam())
            {
                response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
                return response;
            }
            
            PointToPointCDRQueryConfig queryConfig =
                tpProfessionalConfMgrConvertService.queryPointToPointCDRExSopa2Modal(parameters);
            
            SDKResult<PagedList<PointToPointCDR>> cdr = confManagerService.queryPointToPointCDR(queryConfig);
            
            response = tpProfessionalConfMgrConvertService.queryPointToPointCDRExModal2Soap(cdr);
        }
        catch (SDKException ex)
        {
            LOGGER.error("queryPointToPointCDREx method error", ex);
            response.setResultCode((int)ex.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("queryPointToPointCDREx method error", e);
            response.setResultCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        return response;
    }
    
    @Override
    public SynchAdhocConfFreeBusyExResponse synchAdhocConfFreeBusyEx(SynchAdhocConfFreeBusyEx parameters)
    {
        SynchAdhocConfFreeBusyExResponse response = new SynchAdhocConfFreeBusyExResponse();
        
        // 必填参数校验
        if (null == parameters)
        {
            response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
            return response;
        }
        
        Integer duration = DurationUtils.duration2int(parameters.getDuration());
        Date beginTime = DateUtils.toDate(parameters.getBeginTime());
        List<String> confAccessCodes = parameters.getConfAccessCodes();
        
        if (null == duration || null == beginTime)
        {
            response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
            return response;
        }
        
        if (confAccessCodes.isEmpty())
        {
            response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
            return response;
        }
        
        try
        {
            // 查询Adhoc会议忙闲状态变化的数据
            SDKResult<AdhocConfFreeBusyStateList> result =
                confManagerService.synchAdhocConfFreeBusyEx(duration, beginTime, confAccessCodes);
            
            response = tpProfessionalConfMgrConvertService.synchAdhocConfFreeBusyExModal2Soap(result);
        }
        catch (SDKException ex)
        {
            LOGGER.error("synchAdhocConfFreeBusyEx method error", ex);
            response.setResultCode((int)ex.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("synchAdhocConfFreeBusyEx method error", e);
            response.setResultCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        
        return response;
    }
    
    @Override
    public QueryAdhocConferencesExResponse queryAdhocConferencesEx(QueryAdhocConferencesEx parameters)
    {
        QueryAdhocConferencesExResponse response = new QueryAdhocConferencesExResponse();
        
        // 必填参数校验
        if (null == parameters || null == parameters.getQueryConfig()
            || null == parameters.getQueryConfig().getPageParam()
            || null == parameters.getQueryConfig().getPageParam().getCurrentPage()
            || null == parameters.getQueryConfig().getPageParam().getNumberPerPage())
        {
            response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
            return response;
        }
        
        try
        {
            // 查询Ad hoc类型的会议列表 
            SDKResult<AdhocConferencesList> result =
                confManagerService.queryAdhocConferencesEx(tpProfessionalConfMgrConvertService.queryAdhocConferencesExSoap2Modal(parameters));
            
            response = tpProfessionalConfMgrConvertService.queryAdhocConferencesExModal2Soap(result);
        }
        catch (SDKException ex)
        {
            LOGGER.error("queryAdhocConferencesEx method error", ex);
            response.setResultCode((int)ex.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("queryAdhocConferencesEx method error", e);
            response.setResultCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        
        return response;
    }
    
    @Override
    public QueryAdhocConfFreeBusyExResponse queryAdhocConfFreeBusyEx(QueryAdhocConfFreeBusyEx parameters)
    {
        QueryAdhocConfFreeBusyExResponse response = new QueryAdhocConfFreeBusyExResponse();
        
        // 必填参数校验
        if (null == parameters)
        {
            response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
            return response;
        }
        
        Integer duration = DurationUtils.duration2int(parameters.getDuration());
        Date beginTime = DateUtils.toDate(parameters.getBeginTime());
        List<String> confAccessCodes = parameters.getConfAccessCodes();
        
        if (null == duration || null == beginTime)
        {
            response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
            return response;
        }
        
        if (confAccessCodes.isEmpty())
        {
            response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
            return response;
        }
        
        try
        {
            // 查询Ad hoc会议忙闲状态
            SDKResult<AdhocConfFreeBusyStateList> result =
                confManagerService.queryAdhocConfFreeBusyEx(duration, beginTime, confAccessCodes);
            
            response = tpProfessionalConfMgrConvertService.queryAdhocConfFreeBusyExModal2Soap(result);
        }
        catch (SDKException ex)
        {
            LOGGER.error("queryAdhocConfFreeBusyEx method error", ex);
            response.setResultCode((int)ex.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("queryAdhocConfFreeBusyEx method error", e);
            response.setResultCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        return response;
    }
    
    @Override
    public QueryMultiPointCDRExResponse queryMultiPointCDREx(QueryMultiPointCDREx parameters)
    {
        QueryMultiPointCDRExResponse response = new QueryMultiPointCDRExResponse();
        
        if (null == parameters)
        {
            response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
            return response;
        }
        
        if (null == parameters.getQueryConfig().getBeginTime() || null == parameters.getQueryConfig().getDuration()
            || null == parameters.getQueryConfig().getPageParam())
        {
            response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
            return response;
        }
        
        MultiPointCDRQueryConfig queryConfig =
            tpProfessionalConfMgrConvertService.queryMultiPointCDRExSoap2Model(parameters.getQueryConfig());
        
        try
        {
            // 查询Ad hoc会议忙闲状态
            SDKResult<MultiPointCDRResult> result = confManagerService.queryMultiPointCDREx(queryConfig);
            
            response = tpProfessionalConfMgrConvertService.queryMultiPointCDRExModel2Soap(result);
        }
        catch (SDKException ex)
        {
            LOGGER.error("queryMultiPointCDREx method error", ex);
            response.setResultCode((int)ex.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("queryMultiPointCDREx method error", e);
            response.setResultCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        
        return response;
    }
    
    @Override
    public GetContinuousPresenceInfoExResponse getContinuousPresenceInfoEx(GetContinuousPresenceInfoEx parameters)
    {
        GetContinuousPresenceInfoExResponse response = new GetContinuousPresenceInfoExResponse();
        
        if (null == parameters || StringUtils.isEmpty(parameters.getConfId()))
        {
            response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
            return response;
        }
        
        try
        {
            // 查询Ad hoc会议忙闲状态
            SDKResult<ContinuousPresenceCapability> result =
                confManagerService.getContinuousPresenceInfoEx(parameters.getConfId());
            
            response = tpProfessionalConfMgrConvertService.getContinuousPresenceInfoExModal2Soap(result);
        }
        catch (SDKException ex)
        {
            LOGGER.error("getContinuousPresenceInfoEx method error", ex);
            response.setResultCode((int)ex.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("getContinuousPresenceInfoEx method error", e);
            response.setResultCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        
        return response;
    }
    
    @Override
    public QueryConfSiteMCUExResponse queryConfSiteMCUEx(QueryConfSiteMCUEx parameters)
    {
        QueryConfSiteMCUExResponse response = new QueryConfSiteMCUExResponse();
        
        if (null == parameters)
        {
            response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
            return response;
        }
        
        if (StringUtils.isEmpty(parameters.getConfId()) || null == parameters.getSiteUris())
        {
            response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
            return response;
        }
        
        try
        {
            // 查询Ad hoc会议忙闲状态
            SDKResult<List<SiteMCU>> result =
                confManagerService.queryConfSiteMCUEx(parameters.getConfId(),
                    parameters.getSiteUris(),
                    DateUtils.toDate(parameters.getBeginTime()));
            
            response = tpProfessionalConfMgrConvertService.queryConfSiteMCUExModal2Soap(result);
        }
        catch (SDKException ex)
        {
            LOGGER.error("queryConfSiteMCUEx method error", ex);
            response.setResultCode((int)ex.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("queryConfSiteMCUEx method error", e);
            response.setResultCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        
        return response;
    }
    
    @Override
    public GetContinuousPresenceParamExResponse getContinuousPresenceParamEx(GetContinuousPresenceParamEx parameters)
    {
        GetContinuousPresenceParamExResponse response = new GetContinuousPresenceParamExResponse();
        
        if (null == parameters || StringUtils.isEmpty(parameters.getConfId()))
        {
            response.setResultCode(ErrInfo.SDK_PARAM_NOT_COMPLETE_ERRORCODE);
            return response;
        }
        
        String target = parameters.getTarget();
        
        // 不填，转换成(%CP)
        if (StringUtils.isEmpty(target))
        {
            target = ConfigManager.getInstance().getValue("professional.setContinuousPresence.target_(%CP)");
        }
        else if (target.startsWith(ConfigManager.getInstance().getValue("professional.setContinuousPresence.target_("))
            && target.endsWith(ConfigManager.getInstance().getValue("professional.setContinuousPresence.target_)")))
        {
            // 需要将(xxxxx)转换成xxxxx(%CP)
            target =
                target.replaceAll("\\"
                    + ConfigManager.getInstance().getValue("professional.setContinuousPresence.target_("),
                    "");
            target =
                target.replaceAll("\\"
                    + ConfigManager.getInstance().getValue("professional.setContinuousPresence.target_)"),
                    "");
            
            target = target + ConfigManager.getInstance().getValue("professional.setContinuousPresence.target_(%CP)");
        }
        else
        {
            // 将x转换成(%CPx)
            target =
                ConfigManager.getInstance().getValue("professional.setContinuousPresence.target_(%CP") + target
                    + ConfigManager.getInstance().getValue("professional.setContinuousPresence.target_)");
        }
        
        try
        {
            // 查询Ad hoc会议忙闲状态
            SDKResult<ContinuousPresenceParam> result =
                confManagerService.getContinuousPresenceParamEx(parameters.getConfId(), target);
            
            response = tpProfessionalConfMgrConvertService.getContinuousPresenceParamExModal2Soap(result);
        }
        catch (SDKException ex)
        {
            LOGGER.error("getContinuousPresenceParamEx method error", ex);
            response.setResultCode((int)ex.getSdkErrCode());
        }
        catch (Exception e)
        {
            LOGGER.error("getContinuousPresenceParamEx method error", e);
            response.setResultCode(ErrInfo.SDK_SYSTEM_ERRORCODE);
        }
        
        return response;
    }
}
